from typing import Optional, Any, Dict

from pydantic import BaseModel, Field


class EchostrRequest(BaseModel):
    signature: str
    timestamp: str
    nonce: str
    echostr: str


# class Msg(BaseModel):
#     from_user_nickname: str
#     other_user_nickname: str
#     actual_user_nickname: Optional[str] = None


# class WXMessageIn(BaseModel):
#     type: int
#     content: str
#     isgroup: bool
#     msg: Msg
#     # no_need_at: Optional[bool] = False
#     # origin_ctype: int
#     # openai_api_key: Optional[str] = None
#     # gpt_model: Optional[str] = None
#     # session_id: str
#     # receiver: str


class WXWorkFrom(BaseModel):
    """企业微信消息发送者信息"""
    userid: str = Field(description="发送者的用户ID")


class WXWorkText(BaseModel):
    """企业微信文本消息内容"""
    content: str = Field(description="消息文本内容")


class WXWorkIn(BaseModel):
    """企业微信消息输入模型"""
    msgid: str = Field(description="消息ID")
    aibotid: str = Field(description="AI机器人ID")
    chattype: str = Field(description="聊天类型，如single、group等")
    from_: WXWorkFrom = Field(alias="from", description="消息发送者信息")
    msgtype: str = Field(description="消息类型，如text、image等")
    text: Optional[WXWorkText] = Field(None, description="文本消息内容，当msgtype为text时存在")
    # 可以根据需要添加其他消息类型的字段
    # image: Optional[Dict] = Field(None, description="图片消息内容")
    # file: Optional[Dict] = Field(None, description="文件消息内容")


class InstructionIn(BaseModel):
    instruction: str = Field(description="The name of the instruction.")


# class RegistryInfoIn(BaseModel):
#     name: str = Field(description="The name of the user.")
#     phone: str = Field(description="The phone number of the user.")
#     address: str = Field(description="The address of the user.")
#     nickname: str = Field(description="The nickname of the user.")
#     result: str = Field(description="The result code of the operation.")
#     message: str = Field(description="The extra message of the operation.")


# class HumanQueryIn(BaseModel):
#     nn: str = Field(description="The nickname of the user.")
#     role: str = Field(description="The role of the user.")
#     chat_env: str = Field(description="The chat environment of the user, if it's group chat or private chat.")
#     user_id: int = Field(description="The user id of the user in users table.")
#     query: str = Field(description="The query of the user.")